<?php

namespace App\Http\Requests\Config\Yun;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'       => [
                'required',
                Rule::unique('qiniu_config', 'name')->whereNull('deleted_at')
                    ->ignore($this->route('qi_niu_config'))
            ],
            'access_key' => [
                'required',
                'string'
            ],
            'secret_key' => [
                'required',
                'string'
            ],
            'bucket'     => [
                'required',
                Rule::unique('qiniu_config', 'bucket')
                    ->whereNull('deleted_at')
                    ->ignore($this->route('qi_niu_config'))
            ],
            'url'        => [
                'nullable'
            ],
            'status'     => [
                'required',
                'boolean'
            ]
        ];
    }
}
